package drive.Controller;

import drive.Model.Useraddr;
import drive.Service.ServiceInterface.UseraddrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/useraddr")
public class UseraddrController {
    @Autowired
    private UseraddrService useraddrService;

    @PostMapping()
    public String addUseraddr(@RequestBody Useraddr useraddr) {
        return useraddrService.add(useraddr);
    }

    @GetMapping("/{userID}")
    public String getUseraddrByUserID(@PathVariable("userID") int userID) {
        return useraddrService.findByUserID(userID);
    }

    @PutMapping()
    public String updateUseraddr(@RequestBody Useraddr useraddr) {
        return useraddrService.update(useraddr);
    }

    @DeleteMapping("/{addrID}")
    public String deleteUseraddr(@PathVariable("addrID") int addrID) {
        return useraddrService.delete(addrID);
    }
}